﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KProject.Controller;
using KProject.Model;

namespace KProject.View
{
    public partial class FormAbrirConcurso : Form
    {
        private ConcursoController cc;

        public FormAbrirConcurso(ConcursoController cc)
        {
            this.cc = cc;
            InitializeComponent();
        }

        private void FormAbrirConcurso_Load(object sender, EventArgs e)
        {
            cc.CarregarLista(lbConcursos);
        }

        private void bCancelarAbrir_Click(object sender, EventArgs e)
        {
            cc.Concurso = new Concurso();
            this.Close();
        }

        private void bOkAbrir_Click(object sender, EventArgs e)
        {
            try
            {
                cc.CarregarConcurso(lbConcursos);
            }
            catch (VerifyingException ex)
            {
                MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                this.Close();
            }
        }
    }
}
